package com.apptravel.web.controller.admin;

import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by IntelliJ IDEA.
 * User: lishsh
 * Date: 2012-1-11
 * Time: 8:43:39
 * To change this template use File | Settings | File Templates.
 */
@Controller
public class AdminBaseController {

    protected static final   String EDIT = "/edit";

    protected static final String ADD = "/add";

    protected static final String UPDATE = "/update";

    protected static final String DEL = "/del";

    protected String makeResponseHtml(Integer backType,String url){
		String html = "";
		if(backType == 0){
			html = "{\"statusCode\":\"200\",\"message\":\"保存成功\",\"navTabId\":\"\",\"rel\":\"\",\"callbackType\":\"closeCurrent\",\"forwardUrl\":\"\"}";
		}else{
			html = "{\"statusCode\":\"200\",\"message\":\"操作成功\",\"navTabId\":\"\",\"rel\":\"\",\"callbackType\":\"forward\",\"forwardUrl\":\""+url+"\"}";
		}
		return html;
	}


    @InitBinder
	public void initBinder(WebDataBinder binder) {
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
		dateFormat.setLenient(false);
		binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
	}

    
}
